//
//  WBEmoticonButton.swift
//  0829-Weibo
//
//  Created by 毕仲阳 on 16/9/10.
//  Copyright © 2016年 mycompany. All rights reserved.
//

import UIKit

class WBEmoticonButton: UIButton {

    var emoticon:WBEmoticon?{
        didSet{
            //            for button in emoticonButtons {
            //                button.isHidden = true
            //            }
            
            
            //                let button = emoticonButtons[index]
            //                button.isHidden = false
            if emoticon!.type == 0 {
                
                let bundle = WBEmoticonKeyboardViewModel.sharedModel.emoticonBundle
                let image = UIImage(named: "\(emoticon!.path!)/\(emoticon!.png!)", in: bundle, compatibleWith: nil)
                self.setImage(image, for: UIControlState.normal)
                self.setTitle(nil, for: UIControlState.normal)
            }else
            {
                self.setTitle((emoticon!.code! as NSString).emoji(), for: UIControlState.normal)
                self.setImage(nil, for: UIControlState.normal)
                
            }
        }
    }
    
    
}
